package io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.util.HashMap;

public class GetChannel {
private static final int BSIZE=1024;
public static void main(String[] args) throws IOException {
	FileChannel fc=new FileOutputStream("Data.txt").getChannel();
	fc.write(ByteBuffer.wrap("some text ".getBytes()));
	fc.close();
	
	fc=new RandomAccessFile("Data.txt", "rw").getChannel();
	fc.position(fc.size());
	fc.write(ByteBuffer.wrap("some more".getBytes()));
	fc.close();
	
	//HashMap<K, V>
	
	fc=new FileInputStream("Data.txt").getChannel();
	ByteBuffer buffer=ByteBuffer.allocate(BSIZE);
	fc.read(buffer);
	buffer.flip();
	while(buffer.hasRemaining()){
		System.out.print((char)buffer.get());
	}
}
}
